package com.nstar.base.controls
{
 import mx.binding.utils.BindingUtils;
   import mx.controls.ComboBox;
   import mx.core.UIComponent;

   public class ComboBoxEx extends ComboBox
   {
       public function ComboBoxEx()
       {
           super();
       }
       
        protected var textInputReplacement:UIComponent;

        override protected function createChildren():void {
            super.createChildren();

            if ( !textInputReplacement ) {
                if ( itemRenderer != null ) {
                    //删除缺少的TextInput组件
                    removeChild(textInput);

                    //用itemRenderer创建一个实例并添加
                    textInputReplacement = itemRenderer.newInstance();
                    //绑定属性
                    BindingUtils.bindProperty(textInputReplacement, "data", this, "selectedItem", true);
                    addChild(textInputReplacement);
                }
            }
        }

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if ( textInputReplacement ) {
                textInputReplacement.width = unscaledWidth;
                textInputReplacement.height = unscaledHeight;
            }
        }
       
   }
}